using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace Sec_scan漏洞扫描系统.Sec_Service
{
    /// <summary>
    /// 端口扫描服务
    /// </summary>
    public class Sec_PortScan_Service
    {
        /// <summary>
        /// 全端口扫描方法，用于先循环出所有的端口 大约 3 - 4秒能循环完成
        /// </summary>
        /// <param name="port"></param>
        /// <returns></returns>
        public static int PortAll(int port)
        {
            Sec_Api.Sec_PortScan_Service_Api.PortInfoAll = new StringBuilder();//实例化后进行传出
            for(int i = 0;i <= 65535; i++)
            {
                Sec_Api.Sec_PortScan_Service_Api.PortInfoAll.Append(i.ToString());
            }
            return port;
        }
        /// <summary>
        /// 根据端口扫描配置来进行指定的端口扫描
        /// </summary>
        /// <param name="dispose"></param>
        /// <returns></returns>
        public static string PortDispose(string dispose)
        {
            return dispose;
        }
        /// <summary>
        /// TCP 端口扫描
        /// </summary>
        /// <param name="tcp"></param>
        /// <returns></returns>
        public static string TcpScan(string tcp)
        {
            return tcp;
        }
        /// <summary>
        /// syn 端口扫描
        /// </summary>
        /// <param name="syn"></param>
        /// <returns></returns>
        public static string SynScan(string syn)
        {
            UdpClient client = new UdpClient();
            IPAddress remoteIP = IPAddress.Parse("10.60.4.53");  //假设发送给这个IP
            int remotePort = 11000;  //设置端口号
            IPEndPoint remotePoint = new IPEndPoint(remoteIP, remotePort);
            return syn; 
        }
        /// <summary>
        /// UDP 端口扫描
        /// </summary>
        /// <param name="udp"></param>
        /// <returns></returns>
        public static string UdpScan(string udp)
        {
            return udp;
        }
        /// <summary>
        /// icmp 协议探测
        /// </summary>
        /// <param name="icmp"></param>
        /// <returns></returns>
        public static string IcmpScan(string icmp)
        {
            return icmp;
        }
        /// <summary>
        /// ACK 探测
        /// </summary>
        /// <param name="ack"></param>
        /// <returns></returns>
        public static string AckScan(string ack)
        {
            return ack;
        }
    }
}
